package data;
import java.util.ArrayList;

/**
 * 
 * @author William Tran
 * 
 * Class to represent a task within a precedence diagram method
 *
 */
public class PDMNode {
	
	
	
	//early start time for node
	private int earlyStart;
	
	//early end time for node
	private int earlyEnd;
	
	//late start time for node
	private int lateStart;
	
	//late endtiem for node
	private int lateEnd;
	
	//duration of this task
	private int duration;
	
	//key of the node
	private String nodeKey;
	
	//list to hold a pointer to all dependencies
	private ArrayList<PDMNode> dependencies;
	
	//list to hold a pointer to all nodes that depend on this node
	private ArrayList<PDMNode> dependents;
	
	
	/**
	 * Default Constructor
	 */
	public PDMNode () {
		dependencies = new ArrayList<PDMNode>();
		dependents = new ArrayList<PDMNode>();
	}
	
	
	
	/*
	 * 
	 * GETTER AND SETTERS BELOW
	 * 
	 */
	
	/**
	 * Sets the earliest start Time
	 * @param earlyStart - the earliest start time to be set to
	 */
	public void setEarlyStart(int earlyStart) {
		this.earlyStart = earlyStart;
	}
	
	/**
	 * Returns the earliest start time
	 * @return earlyStart - the earliest start time
	 */
	public int getEarlyStart() {
		return earlyStart;
	}
	
	/**
	 * Sets the earliest end time
	 * @param earlyEnd - the earliest end time to be set to
	 */
	public void setEarlyEnd(int earlyEnd) {
		this.earlyEnd = earlyEnd;
	}
	
	/**
	 * Returns the earliest end time
	 * @return earlyEnd - the earliest end time
	 */
	public int getEarlyEnd() {
		return earlyEnd;
	}
	
	/**
	 * Sets the latest start time
	 * @param lateStart - the latest start time to be set to
	 */
	public void setLateStart(int lateStart) {
		this.lateStart = lateStart;
	}
	
	/**
	 * Returns the latest start time
	 * @return lateStart - the latest start time
	 */
	public int getLateStart() {
		return lateStart;
	}
	
	/**
	 * Sets the latest end time
	 * @param lateEnd - the latest end time to be set to
	 */
	public void setLateEnd(int lateEnd) {
		this.lateEnd = lateEnd;
	}
	
	/**
	 * Returns the latest end time
	 * @return lateEnd - the latest end time
	 */
	public int getLateEnd() {
		return lateEnd;
	}






	/**
	 * 
	 * @param dependancies
	 */
	public void setDependancies(ArrayList<PDMNode> dependancies) {
		this.dependencies = dependancies;
	}






	/**
	 * Returns the list of nodes that this node depends on
	 * @return dependencies - the list of task that this node depends on
	 */
	public ArrayList<PDMNode> getDependancies() {
		return dependencies;
	}






	/**
	 * Set the list of dependents to a incoming list
	 * @param dependents
	 */
	public void setDependents(ArrayList<PDMNode> dependents) {
		this.dependents = dependents;
	}






	/**
	 * Returns the list of nodes that depend on this task
	 * @return dependents - the list of nodes that depend on this task
	 */
	public ArrayList<PDMNode> getDependents() {
		return dependents;
	}


	/**
	 * Sets the duration of this task
	 * @param duration
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}


	/**
	 * Returns the duration of this task
	 * @return duration
	 */
	public int getDuration() {
		return duration;
	}


	/**
	 * Sets the task id of this node
	 * @param nodeKey - id to be set to
	 */
	public void setNodeKey(String nodeKey) {
		this.nodeKey = nodeKey;
	}


	/**
	 * Returns the task id
	 * @return nodeKey - the task id
	 */
	public String getNodeKey() {
		return nodeKey;
	}

	
	public String toString()
	{
		String retval = nodeKey + " : " + duration + " : ";
		for(PDMNode n: this.dependencies)
		{
			retval += n.nodeKey + ", ";
		}
		retval = retval.substring(0, retval.length() - 2);
		return retval;
	}
}
